package cn.tedu.ivos.repair.controller;

import cn.tedu.ivos.base.response.JsonResult;
import cn.tedu.ivos.repair.pojo.dto.RepairParam;
import cn.tedu.ivos.repair.pojo.dto.RepairQuery;
import cn.tedu.ivos.repair.pojo.vo.RepairVO;
import cn.tedu.ivos.repair.service.RepairService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/v1/repair")
@Slf4j
public class RepairController {
    @Autowired
    private RepairService repairService;
    @GetMapping("/select")
    public JsonResult selectRepair(RepairQuery repairQuery){
        log.debug("查询维修单开始 {}", repairQuery );
       List<RepairVO> repairVOs = repairService.selectRepair(repairQuery);
        return JsonResult.ok(repairVOs);
    }
    @PostMapping("/add")
    public JsonResult addRepair(RepairParam repairParam){
        log.debug("添加维修单开始 {}", repairParam);
        repairService.addRepair(repairParam);
        return JsonResult.ok();
    }
    @PostMapping("/delete/{id}")
    public JsonResult deleteRepair(@PathVariable Long id){
        log.debug("删除维修单开始 {}", id);
        repairService.deleteRepair(id);
        return JsonResult.ok();
    }
}
